package com.eight.cloud.payment.controller;

import com.eight.cloud.core.global.result.Result;
import com.eight.cloud.payment.common.enums.PayStrategyEnum;
import com.eight.cloud.payment.facade.OrderFacade;
import com.eight.cloud.payment.model.vo.SubRefundOrderVo;
import com.eight.cloud.payment.service.IThirdPayService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* 子商户支付订单信息 管理接口
*
* @ClassName: SubPayOrderController
* @Author TXC
* @Date 2025-01-07 17:22
*/
@RestController
@RequestMapping("/subPayOrder")
public class SubPayOrderController {

    @Resource
    private OrderFacade orderFacade;
    @Resource
    IThirdPayService thirdPayService;

    /**
     * 退款
     * @param uuid 订单uuid
     * @return Result<?>
     */
    @GetMapping("/refundPayOrder/{uuid}")
    public Result<?> refundPayOrder(@PathVariable("uuid") String uuid) {
        SubRefundOrderVo subRefundOrderVo = orderFacade.refundPayOrder(uuid);
        String result = thirdPayService.refund(PayStrategyEnum.getEnum(subRefundOrderVo.getPayChannel(), subRefundOrderVo.getTradeType()), subRefundOrderVo, null);
        return Result.ok(result);
    }

}
